package com.heaven.service;

import com.heaven.mapper.LeadMapper;
import com.heaven.pojo.Lead;
import com.heaven.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class LeadServiceImpl implements LeadService{
    @Autowired
    private LeadMapper leadMapper;
    @Override
    public PageResult addreList(PageResult pageResult) {
        int size=pageResult.getPageSize();
        int startNum=(pageResult.getPageNum()-1)*size;
        String query=pageResult.getQuery();
        List<Lead> row=leadMapper.addreList(size,startNum,query);
        long total=leadMapper.findAddreList(query);
        pageResult.setTotal(total).setRows(row);
        return pageResult;
    }
    @Override
    @Transactional
    public void deleteLeadById(Integer id) {
        leadMapper.deleteLeadById(id);
    }

    @Override
    public Lead findLeadById(Integer id) {
        return leadMapper.findLeadById(id);
    }

    @Override
    @Transactional
    public void updateLead(Lead lead) {
        leadMapper.updateLead(lead);
    }
}
